

#include "common.hpp"


int main()
{
   // 1. 检测命名管道
   if (mkfifo(Pipename.c_str(), MOODE) < 0 )
   {
       perror(" mkfifo ");
       exit(2);
   }
    
   // 2. 文件操作
   int fd = open(PipeAddress.c_str(), O_WRONLY);
   if (!fd)
   {
      perror(" open ");
      exit(-1);
   }


   // 3. 处理数据
   char buff[SIZE];
   while (1)
   {
    ssize_t byte = read(fd, buff, sizeof buff - 1);
    if (byte > 0)
    {
        cout << " read nomal "   << endl;
    }else if ( byte == 0)
    {
        cout << " write close " << endl;
    }else
    {
        cout << " read error "  << endl;
    }

    
   }





   // 4. 关闭文件
   close(fd);
    return 0;
}
 






